package com.letv.mytest.dao;

import javax.sql.DataSource;

import jmind.core.manager.DataSourceManager;
import jmind.pigg.datasource.DataSourceFactory;
import jmind.pigg.datasource.SimpleDataSourceFactory;
import jmind.pigg.operator.Mango;
import jmind.pigg.plugin.spring.AbstractMangoFactoryBean;

public class DaoFactoryBean extends AbstractMangoFactoryBean {

    @Override
    public Mango getMangoInstance() {
        return mango;
    }

    private static Mango mango = createMango();

    private static Mango createMango() {
        Mango m = Mango.newInstance();
        DataSourceFactory dsf = new SimpleDataSourceFactory(getDataSource());
        m.setDataSourceFactory(dsf);
        return m;
    }

    private static DataSource getDataSource() {
        return DataSourceManager.getInstance().getResource("letv_boss");
    }
}
